package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Menu;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MenuDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "菜单id")
    private Integer id;

    @ApiModelProperty(value = "菜单名")
    private String title;

    @ApiModelProperty(value = "图标")
    private String icon;

    @ApiModelProperty(value = "类型:0:菜单;1:iframe;2:外连，3：按钮")
    private Integer type;

    @ApiModelProperty(value = "路径")
    private String path;

    @ApiModelProperty(value = "排序")
    private Integer sort;

    @ApiModelProperty(value = "是否隐藏 1true 0false ")
    private Integer hidden;

    @ApiModelProperty(value = "是否隐藏面包屑 1true 0false")
    private Integer breadCrumb;

    @ApiModelProperty(value = "父ID")
    private Integer parentId;

    @ApiModelProperty(value = "是否启用：1启用0禁用")
    private Integer enabled;


    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;


    public MenuDTO() {}

    public MenuDTO(Menu entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static MenuDTO convert(Menu entity) {
        return new MenuDTO(entity);
    }

    public static List<MenuDTO> convertList(List<Menu> list) {
        List<MenuDTO> resultList = new ArrayList<>();
        for (Menu entity : list) {
            resultList.add(new MenuDTO(entity));
        }
        return resultList;
    }}
